
// import oimo.collision.*;
// import oimo.collision.broadphase.*;
// import oimo.collision.broadphase.bruteforce.*;
// import oimo.collision.narrowphase.*;
// import oimo.dynamics.*;
// import oimo.dynamics.constraint.*;
// import oimo.dynamics.constraint.contact.*;
// import oimo.dynamics.constraint.solver.*;
// import oimo.dynamics.rigidbody.*;
// import oimo.math.*;

import { MathUtil } from "./MathUtil";
import { PositionCorrectionAlgorithm } from "../dynamics/constraint/PositionCorrectionAlgorithm";
import { ConstraintSolverType } from "../dynamics/constraint/solver/ConstraintSolverType";

/**
 * Setting provides advenced parameters used by the physics simulation.
 */
export class Setting {
	// default shape parameters
	public static defaultFriction: number = 0.2;
	public static defaultRestitution: number = 0.2;
	public static defaultDensity: number = 1;
	public static defaultCollisionGroup: number = 1;
	public static defaultCollisionMask: number = 1;

	// velocity limitations
	public static maxTranslationPerStep: number = 20;
	public static maxRotationPerStep: number = MathUtil.PI;

	// dynamic BVH
	public static bvhProxyPadding: number = 0.1;
	public static bvhIncrementalCollisionThreshold: number = 0.45;

	// GJK/EPA
	public static defaultGJKMargin: number = 0.05;
	public static enableGJKCaching: boolean = true;
	public static maxEPAVertices: number = 128;
	public static maxEPAPolyhedronFaces: number = 128;

	// general constraints
	public static contactEnableBounceThreshold: number = 0.5;
	public static velocityBaumgarte: number = 0.2;
	public static positionSplitImpulseBaumgarte: number = 0.4;
	public static positionNgsBaumgarte: number = 1.0;

	// contacts
	public static contactUseAlternativePositionCorrectionAlgorithmDepthThreshold: number = 0.05;
	public static defaultContactPositionCorrectionAlgorithm: number = PositionCorrectionAlgorithm._BAUMGARTE;
	public static alternativeContactPositionCorrectionAlgorithm: number = PositionCorrectionAlgorithm._SPLIT_IMPULSE;
	public static contactPersistenceThreshold: number = 0.05;
	public static maxManifoldPoints: number = 4;

	// joints
	public static defaultJointConstraintSolverType: number = ConstraintSolverType._ITERATIVE;
	public static defaultJointPositionCorrectionAlgorithm: number = PositionCorrectionAlgorithm._BAUMGARTE;
	public static jointWarmStartingFactorForBaungarte: number = 0.8;
	public static jointWarmStartingFactor: number = 0.95;
	public static minSpringDamperDampingRatio: number = 1e-6;
	public static minRagdollMaxSwingAngle: number = 1e-6;
	public static maxJacobianRows: number = 6;

	// direct MLCP solver
	public static directMlcpSolverEps: number = 1e-9;

	// islands
	public static islandInitialRigidBodyArraySize: number = 128;
	public static islandInitialConstraintArraySize: number = 128;

	// sleeping
	public static sleepingVelocityThreshold: number = 0.2;
	public static sleepingAngularVelocityThreshold: number = 0.5;
	public static sleepingTimeThreshold: number = 1.0;
	public static disableSleeping: boolean = false;

	// slops
	public static linearSlop: number = 0.005;
	public static angularSlop: number = 1 * MathUtil.TO_RADIANS;
}
